//app.js
import {
    login,
    getUserInfo,
    getFAIUserInfo
} from './requestFunctions/loginRequestFunctions';
App({
    onLaunch: function (options) {
        console.log("on launch");
        const that = this;
        // this.getUserInfo().then(() => {
        //     console.log(that.globalData);
        // })
        // Do something initial when launch.
    },
    onShow: function (options) {
        // Do something when show.
    },
    onHide: function () {
        // Do something when hide.
    },
    onError: function (msg) {
        // console.log(msg)
    },
    initUserInfo: function () {
        const that = this;
        return login()
            .then((faiSessionKey) => {
                return Promise.all([getUserInfo(), getFAIUserInfo(faiSessionKey)])
            })
            .then(twoUserInfo => {
                const userInfo = twoUserInfo[0];
                const faiUserInfo = twoUserInfo[1];
                that.globalData.userInfo = userInfo;
                that.globalData.faiUserInfo = faiUserInfo;
                // console.log(that.globalData);
            });
    },
    globalData: {
        userInfo: null,
        faiUserInfo: null
    }
})